from google.appengine.ext import db
from google.appengine.tools import bulkloader
import datetime

class Question(db.Model):
    year = db.DateProperty()
    level = db.CategoryProperty()
    author = db.StringProperty()
    question = db.TextProperty()
    gen_category = db.CategoryProperty()
    spec_category = db.CategoryProperty()
    answer = db.TextProperty()
    id = db.IntegerProperty()

class QuestionLoader(bulkloader.Loader):    
    def __init__(self):
        bulkloader.Loader.__init__(self, 'Question',
                                   [('year', lambda x: datetime.datetime.strptime(x, '%Y').date()),
                                    ('author', str),
                                    ('level', str),
                                    ('gen_category', str),
                                    ('spec_category', str),
                                    ('question', str),
                                    ('answer', str),
                                    ('id', int), ])

loaders = [QuestionLoader]       